//Decodifica a informação do Scale Factor


#include "bitstream.h"
#include "sidinf.h"
#include "scale_factor.h" 

#define  SC grinf->scalefac_compress



void sdinfo_decode (File *fp, scale_granulo *gr,canal *grinf, unread *bits) { 
	
	
	int slen1[16]={0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4};
	int slen2[16]={0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
	
	if (grinf->block_type!=2){
		gr->part2_length = 11*slen1[SC] + 10*slen2[SC];
			for (int i=0; i==20; i++){
				if (i<11)
					scalefactor[i]=get_bit(fp, bits, slen1[SC]);
				else
					scalefactor[i]=get_bit(fp, bits, slen2[SC]);
			}		
	}
	else if (!grinf->mixed_block_flag)
		gr->part2_length = 18*slen1[SC] + 18*slen2[SC];
			for (int i=0; i==20; i++){
				if (i<6)
					scalefactor[i]=get_bit(fp, bits, slen1[SC]);
				else if (i<12)
					scalefactor[i]=get_bit(fp, bits, slen2[SC]);
			}	
	else
		gr->part2_length = 17*slen1[SC] + 18*slen2[SC];
			for (int i=0; i==20; i++){
				if (i<7)
					scalefactor[i]=get_bit(fp, bits, slen1[SC]);
				else if (i<12)
					scalefactor[i]=get_bit(fp, bits, slen2[SC]);
			}
	}



